''微信公众号关注：VB小源码
''QQ群：344402874
''博客：https://www.cnblogs.com/vbee/
''个人微信：vbee_club

Public Class Form1
  Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Dim new_key As Cls_RSA.Create_key_type = Cls_RSA.Create_pub_pri_key
    RichTextBox2.Text = new_key.Private_key
    RichTextBox1.Text = new_key.Public_key
  End Sub

  Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
    If RichTextBox1.Text = "" Then MessageBox.Show("公钥不能为空") ： Exit Sub
    TextBox1.Text = Cls_RSA.RSAEncrypt(RichTextBox1.Text, TextBox3.Text)
  End Sub

  Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
    If RichTextBox2.Text = "" Then MessageBox.Show("私钥不能为空") ： Exit Sub
    TextBox2.Text = Cls_RSA.RSADecrypt(RichTextBox2.Text, TextBox1.Text)
  End Sub

  Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
    If RichTextBox2.Text = "" Then MessageBox.Show("私钥不能为空") ： Exit Sub
    TextBox5.Text = Cls_RSA.RSA_Sign(RichTextBox2.Text, TextBox4.Text)
  End Sub

  Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
    If RichTextBox1.Text = "" Then MessageBox.Show("公钥不能为空") ： Exit Sub
    Dim tf As Boolean = Cls_RSA.RSA_Verify(RichTextBox1.Text, TextBox4.Text, TextBox5.Text)
    If tf Then
      MessageBox.Show("签名验证成功!", "VB小源码", Nothing, MessageBoxIcon.Information)
    Else
      MessageBox.Show("签名验证失败!", "VB小源码", Nothing, MessageBoxIcon.Error)
    End If

  End Sub
End Class
